package com.wz.project.tsj.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.project.tsj.domain.MsgTsj;
import com.wz.project.tsj.service.IMsgTsjService;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.common.utils.poi.ExcelUtil;
import com.wz.framework.web.page.TableDataInfo;

/**
 * 提升机监控Controller
 * 
 * @author wz
 * @date 2023-12-26
 */
@Controller
@RequestMapping("/tsj/tsj")
public class MsgTsjController extends BaseController
{
    private String prefix = "tsj/tsj";

    @Autowired
    private IMsgTsjService msgTsjService;

    @RequiresPermissions("tsj:tsj:view")
    @GetMapping()
    public String tsj()
    {
        return prefix + "/tsj";
    }

    /**
     * 查询提升机监控列表
     */
//    @RequiresPermissions("tsj:tsj:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MsgTsj msgTsj)
    {
        startPage();
        List<MsgTsj> list = msgTsjService.selectMsgTsjList(msgTsj);
        return getDataTable(list);
    }

    /**
     * 导出提升机监控列表
     */
    @RequiresPermissions("tsj:tsj:export")
    @Log(title = "提升机监控", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MsgTsj msgTsj)
    {
        List<MsgTsj> list = msgTsjService.selectMsgTsjList(msgTsj);
        ExcelUtil<MsgTsj> util = new ExcelUtil<MsgTsj>(MsgTsj.class);
        return util.exportExcel(list, "tsj");
    }

    /**
     * 新增提升机监控
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存提升机监控
     */
    @RequiresPermissions("tsj:tsj:add")
    @Log(title = "提升机监控", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MsgTsj msgTsj)
    {
        return toAjax(msgTsjService.insertMsgTsj(msgTsj));
    }

    /**
     * 修改提升机监控
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        MsgTsj msgTsj = msgTsjService.selectMsgTsjById(id);
        mmap.put("msgTsj", msgTsj);
        return prefix + "/edit";
    }

    /**
     * 修改保存提升机监控
     */
    @RequiresPermissions("tsj:tsj:edit")
    @Log(title = "提升机监控", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MsgTsj msgTsj)
    {
        return toAjax(msgTsjService.updateMsgTsj(msgTsj));
    }

    /**
     * 删除提升机监控
     */
    @RequiresPermissions("tsj:tsj:remove")
    @Log(title = "提升机监控", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(msgTsjService.deleteMsgTsjByIds(ids));
    }
}
